{extend name="adminblue/base" /}
{block name="resources"/}
<style>
.table-class input{color:#666;width:206px;margin-bottom: 0px;border: 1px solid #ccc;}
.table-class input.sort{width: auto;text-align: center;}
.tip-box{line-height: 150px;text-align: center;}
</style>
{/block}
{block name="right_tab"}
<li><a href="{:__URL('ADMIN_MAIN/goods/addgoodsgroup')}"><i class="fa fa-plus-circle"></i>&nbsp;添加商品标签</a></li>
{/block}
{block name="main"}
<table class="table-class">
	<colgroup>
		<col style="width: 10%;">
		<col style="width: 70%;">
		<col style="width: 20%;">
	</colgroup>
	<thead>
		<tr align="center">
			<th>排序</th>
			<th style="text-align: left;">商品标签</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
<script type="text/javascript">
$(".table-class input").live("change",function(){
	var fieldid = $(this).attr('fieldid');
	var fieldname = $(this).attr('fieldname');
	var fieldvalue = $(this).val();
	$.ajax({
		type:"post",
		url:"{:__URL('ADMIN_MAIN/goods/modifygoodsgroupfield')}",
		data:{'fieldid':fieldid,'fieldname':fieldname,'fieldvalue':fieldvalue},
		success: function (data) {
			if(data>0){
				showTip("操作成功","success");
			}else{
				showTip("操作成功","error");
			}
		}
	});
});

function tab_switch(module_id){
	if($(".pid_"+module_id).css('display') != 'none'){
		$(".tab_jian_"+module_id).hide();
		$(".tab_jia_"+module_id).show();
		$(".pid_"+module_id).hide(300);
	}else{
		$(".tab_jian_"+module_id).show();
		$(".tab_jia_"+module_id).hide();
		$(".pid_"+module_id).show(500);
	}
}

/* 删除分类 */
function delGroup(group_id){
	$( "#dialog" ).dialog({
		buttons: {
			"确定": function() {
				$(this).dialog('close');
				$.ajax({
					type:"post",
					url:"{:__URL('ADMIN_MAIN/goods/deletegoodsgroup')}",
					data:{'group_id':group_id},
					dataType : "json",
					success:function (data) {
						if(data['code'] > 0){
							showMessage('success', data["message"],"{:__URL('ADMIN_MAIN/goods/goodsgrouplist')}");
						}else{
							showMessage('error', data["message"]);
						}
					}
				});
			},
			"取消,#e57373":function(){
				$(this).dialog('close');
			}
		},
		contentText:"你确定删除吗？",
		title:"消息提醒"
	});
}

function LoadingInfo(page_index) {
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/goods/goodsGroupList')}",
		data : {
			"page_index" : page_index,
			"page_size" : $("#showNumber").val()
		},
		success : function(data) {
			var html = '';
			if (data["data"].length > 0) {
				for (var i = 0; i < data["data"].length; i++) {
					html +='<tr class="pid_0" style="height: 30px;">';
					html +='<td style="text-align: center;"><input type="text" class="sort" fieldid="'+data["data"][i]['group_id']+'" fieldname="sort" value="'+data["data"][i]['sort']+'" size="1"></td>';	
					/* html +='<td style="text-align: center;">';
					if(data["data"][i]['picture']['pic_cover'] != ''){
						html +='<img src="__ROOT__/'+data["data"][i]['picture']['pic_cover']+'" style="height:30px;">';	
					}else{
						html +='<img src="__STATIC__/images/left_agent_commission.png" style="height:30px;">';	
					}
					html +='</td>';	 */
					
					html +='<td><input type="text" fieldid="'+data["data"][i]['group_id']+'" fieldname="group_name" value="'+data["data"][i]['group_name']+'"></td>';	
					/* if(data["data"][i]["is_visible"] == 1){
						html +='<td style="text-align: center;">是</td>';
						
					}else{
						html +='<td style="text-align: center;">否</td>';
					} */
					html +='<td style="text-align: center;"><a href="'+__URL('ADMIN_MAIN/goods/updategoodsgroup?group_id='+data["data"][i]['group_id'])+'">修改</a>&nbsp;&nbsp;';	
					html +='<a href="javascript:void(0);" onclick="delGroup('+data["data"][i]['group_id']+')">删除</a></td>';	
					html +='</tr>';
				}
			} else {
				html += '<tr align="center"><th colspan="3" style="text-align: center;font-weight: normal;background:#ffffff;">';
				html += '<div class="tip-box">';
				html += '当前系统还没有商品标签，<a href="'+__URL('ADMIN_MAIN/goods/addgoodsgroup')+'">马上添加</a>';
				html += '</div>';
				html += '</th></tr>';
				
			}
			$(".table-class tbody").html(html);
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}
</script>
{/block}